<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  var str = "abcxyz";

  // 字符转编码
  console.log( str.charCodeAt(0) );
  console.log( str.charCodeAt(1) );
  console.log( str.charCodeAt(2) );
  console.log( str.charCodeAt(3) );
  console.log( str.charCodeAt(4) );
  console.log( str.charCodeAt(5) );

  // 编码转字符
  console.log( String.fromCharCode(97) );
  console.log( String.fromCharCode(98) );
  console.log( String.fromCharCode(99) );

  // 字符转编码
  console.log( "中文".charCodeAt(0) )
  console.log( "中文".charCodeAt(1) )

  // 编码转字符
  console.log( String.fromCharCode(20013) );
  console.log( String.fromCharCode(25991) );
</script>
</html>